/**
 * Created by huxia on 2016/12/9.
 */
var Area = require('./db')['crm_area'];

Area.findById = function (aid) {
    return Area.findOne({where: {area_id: aid}});
};

Area.findByPid = function (pid) {
    return Area.findAll({
        attributes:['area_id','area_name'],
        where: {parent_id: pid}
    });
};

// Updated by Huxiao at 2016/12/8
Area.findCapital = function (p_id) {
    return Area.findOne({
        where:{
            parent_id:p_id
        }
    });
};

module.exports = Area;